I am using a form to sort a report, but I can't seem to get the "clear form" button to work. I used the wizard when I installed the button, using the clear form option under the form option list. What I want to be able to do is clear the information on the drop down combo box in case I want to change the sort order. This is what the code looks like now:
Option Compare Database -
Private Sub close_Click()
-
On Error GoTo Err_close_Click
-
-
-
DoCmd.close
-
-
Exit_close_Click:
-
Exit Sub
-
-
Err_close_Click:
-
MsgBox Err.Description
-
Resume Exit_close_Click
-
-
End Sub
-
-
Private Sub cmdSetSort_Click()
-
-
Dim strSQL As String, intCounter As Integer
-
'Build strSQL String
-
For intCounter = 1 To 4
-
If Me("cboSort" & intCounter) <> "" Then
-
strSQL = strSQL & "[" & Me("cboSort" & intCounter) & "]"
-
If Me("Chk" & intCounter) = True Then
-
strSQL = strSQL & " DESC"
-
End If
-
strSQL = strSQL & ", "
-
End If
-
Next
-
-
If strSQL <> "" Then
-
'Strip Last Comma & Space
-
strSQL = Left(strSQL, (Len(strSQL) - 2))
-
'Set the OrderBy property
-
Reports![rptPersonnel].OrderBy = strSQL
-
Reports![rptPersonnel].OrderByOn = True
-
Else
-
Reports![rptPersonnel].OrderByOn = False
-
-
End If
-
-
End Sub
-
-
-
Private Sub Form_Open(Cancel As Integer)
-
' Open the report maximized, in Print Preview
-
DoCmd.OpenReport "rptPersonnel", acViewPreview
-
DoCmd.Maximize
-
End Sub
-
-
Private Sub Refresh_Click()
-
On Error GoTo Err_Refresh_Click
-
-
-
DoCmd.DoMenuItem acFormBar, acRecordsMenu, 5, , acMenuVer70
-
-
Exit_Refresh_Click:
-
Exit Sub
-
-
Err_Refresh_Click:
-
MsgBox Err.Description
-
Resume Exit_Refresh_Click
-
-
End Sub
Not sure what I'm doing wrong, but I would appreciate some help. Also attached is a picture of what my sort box looks like.
1 5685
I am using a form to sort a report, but I can't seem to get the "clear form" button to work. I used the wizard when I installed the button, using the clear form option under the form option list. What I want to be able to do is clear the information on the drop down combo box in case I want to change the sort order. This is what the code looks like now:
Option Compare Database -
Private Sub close_Click()
-
On Error GoTo Err_close_Click
-
-
-
DoCmd.close
-
-
Exit_close_Click:
-
Exit Sub
-
-
Err_close_Click:
-
MsgBox Err.Description
-
Resume Exit_close_Click
-
-
End Sub
-
-
Private Sub cmdSetSort_Click()
-
-
Dim strSQL As String, intCounter As Integer
-
'Build strSQL String
-
For intCounter = 1 To 4
-
If Me("cboSort" & intCounter) <> "" Then
-
strSQL = strSQL & "[" & Me("cboSort" & intCounter) & "]"
-
If Me("Chk" & intCounter) = True Then
-
strSQL = strSQL & " DESC"
-
End If
-
strSQL = strSQL & ", "
-
End If
-
Next
-
-
If strSQL <> "" Then
-
'Strip Last Comma & Space
-
strSQL = Left(strSQL, (Len(strSQL) - 2))
-
'Set the OrderBy property
-
Reports![rptPersonnel].OrderBy = strSQL
-
Reports![rptPersonnel].OrderByOn = True
-
Else
-
Reports![rptPersonnel].OrderByOn = False
-
-
End If
-
-
End Sub
-
-
-
Private Sub Form_Open(Cancel As Integer)
-
' Open the report maximized, in Print Preview
-
DoCmd.OpenReport "rptPersonnel", acViewPreview
-
DoCmd.Maximize
-
End Sub
-
-
Private Sub Refresh_Click()
-
On Error GoTo Err_Refresh_Click
-
-
-
DoCmd.DoMenuItem acFormBar, acRecordsMenu, 5, , acMenuVer70
-
-
Exit_Refresh_Click:
-
Exit Sub
-
-
Err_Refresh_Click:
-
MsgBox Err.Description
-
Resume Exit_Refresh_Click
-
-
End Sub
Not sure what I'm doing wrong, but I would appreciate some help. Also attached is a picture of what my sort box looks like.
Never mind, I figured out the answer by myself. For those that are interested about the answer though, here is what I figured out: -
Private Sub cmdClear_Click()
-
On Error Resume Next
-
Me.cboSort1 = ""
-
Me.cbosort2 = ""
-
Me.cboSort3 = ""
-
Me.cboSort4 = ""
-
cboSort1.SetFocus
-
End Sub
Hope this helps those of us out there that are still trying to puzzle their way through VBA and Access.
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Max Harvey |
last post by:
Hi,
I made up a nice little form which had its own sub form in it.
I made a litle VB code so that when I pressed a button it would move
form the form (frmConference) to the subform...
|
by: Steve |
last post by:
I have a form with about 25 fields. In the BeforeUpdate event of the form, I
have code that sets the default value of each field to its current value. For a
new record, I can put the focus in any...
|
by: StriderBob |
last post by:
Situation :
FormX is mdi child form containing 2 ListViews
ListView1 contains a list of table names and 4 sub items with data about
each table.
ListView2 contains a list of the columns on each...
|
by: Cleako |
last post by:
Here is my dilema.
I have a validation summary that I use soley for my Required Field
Validators. I have it setup to run from a Page.Validate call in the
code-behind, this is because I need to...
|
by: Flack |
last post by:
I have pasted at the end of this message a small sample program I whipped up
to do some testing.
It's a form with a datagrid and two buttons. Each button clears the
dataTable that is the source...
|
by: dpierson |
last post by:
I have just converted one of my applications from .Net 1.1 / VS2003 to
..Net 2.0 / VS2005. I'm now seeing some different behavior in my app.
Here's a simple case description:
Form 1:
Stock...
|
by: plumba |
last post by:
Ok, another query....
I have a checkbox at the bottom of my form which when checked unhides a <div> block which displays the submit button.
The problem I have is when the clear form button is...
|
by: johnacooke |
last post by:
I have a HTML form that is generated in part by PHP. The action
attribute on the form tag calls itself, so that I can validate the
fields without using any other form of code like Javascript to...
|
by: karsagarwal |
last post by:
I have a bounded form and after I click the button to update/save. THe
fields are still there. Is there a way to clear off the fields in the
bounded form.
Thanks,
SA
Here's the code that I...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
| |